void init_cpu_khz(void)
{
u64 __cpu_khz = 1000000ULL << 32;
- struct vcpu_time_info *info;
- info = &HYPERVISOR_shared_info->vcpu_info[0].time;
+ struct vcpu_time_info *info = &vcpu_info(0)->time;
do_div(__cpu_khz, info->tsc_to_system_mul);
if (info->tsc_shift < 0)
cpu_khz = __cpu_khz << -info->tsc_shift;
* Reads a consistent set of time-base values from Xen, into a shadow data
* area.
*/
-static void get_time_values_from_xen(void)
+static void get_time_values_from_xen(int cpu)
{
- shared_info_t *s = HYPERVISOR_shared_info;
struct vcpu_time_info *src;
struct shadow_time_info *dst;
- src = &s->vcpu_info[smp_processor_id()].time;
- dst = &per_cpu(shadow_time, smp_processor_id());
+ src = &vcpu_info(cpu)->time;
+ dst = &per_cpu(shadow_time, cpu);
do {
dst->version = src->version;
struct vcpu_time_info *src;
struct shadow_time_info *dst;
- src = &HYPERVISOR_shared_info->vcpu_info[cpu].time;
+ src = &vcpu_info(cpu)->time;
dst = &per_cpu(shadow_time, cpu);
rmb();
* overflowed). Detect that and recalculate
* with fresh values.
*/
- get_time_values_from_xen();
+ get_time_values_from_xen(cpu);
continue;
}
} while (read_seqretry(&xtime_lock, seq) ||
nsec = tv->tv_nsec - get_nsec_offset(shadow);
if (time_values_up_to_date(cpu))
break;
- get_time_values_from_xen();
+ get_time_values_from_xen(cpu);
}
sec = tv->tv_sec;
__normalize_time(&sec, &nsec);
barrier();
time = shadow->system_timestamp + get_nsec_offset(shadow);
if (!time_values_up_to_date(cpu))
- get_time_values_from_xen();
+ get_time_values_from_xen(cpu);
barrier();
} while (local_time_version != shadow->version);
write_seqlock(&xtime_lock);
do {
- get_time_values_from_xen();
+ get_time_values_from_xen(cpu);
/* Obtain a consistent snapshot of elapsed wallclock cycles. */
delta = delta_cpu =
return;
}
#endif
- get_time_values_from_xen();
+ get_time_values_from_xen(0);
processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
per_cpu(processed_system_time, 0) = processed_system_time;
{
init_cpu_khz();
- get_time_values_from_xen();
+ get_time_values_from_xen(0);
processed_system_time = per_cpu(shadow_time, 0).system_timestamp;
per_cpu(processed_system_time, 0) = processed_system_time;
prefetchw(&mm->mmap_sem);
/* get the address */
- address = HYPERVISOR_shared_info->vcpu_info[
- smp_processor_id()].arch.cr2;
+ address = current_vcpu_info()->arch.cr2;
info.si_code = SEGV_MAPERR;
#include <xen/interface/nmi.h>
#include <asm/ptrace.h>
#include <asm/page.h>
-#if defined(__i386__)
-# ifdef CONFIG_X86_PAE
-# include <asm-generic/pgtable-nopud.h>
-# else
-# include <asm-generic/pgtable-nopmd.h>
-# endif
-#endif
extern shared_info_t *HYPERVISOR_shared_info;
+#define vcpu_info(cpu) (HYPERVISOR_shared_info->vcpu_info + (cpu))
+#define current_vcpu_info() vcpu_info(smp_processor_id())
+
#ifdef CONFIG_X86_32
extern unsigned long hypervisor_virt_start;
#endif
#ifndef __ASSEMBLY__
-#ifdef CONFIG_SMP
-#define __vcpu_id smp_processor_id()
-#else
-#define __vcpu_id 0
-#endif
-
/*
* The use of 'barrier' in the following reflects their use as local-lock
* operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
* includes these barriers, for example.
*/
-#define __raw_local_save_flags() \
- (&HYPERVISOR_shared_info->vcpu_info[__vcpu_id])->evtchn_upcall_mask;
+#define __raw_local_save_flags() (current_vcpu_info()->evtchn_upcall_mask)
#define raw_local_save_flags(flags) \
do { (flags) = __raw_local_save_flags(); } while (0)
do { \
vcpu_info_t *_vcpu; \
barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
+ _vcpu = current_vcpu_info(); \
if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
barrier(); /* unmask then check (avoid races) */ \
if (unlikely(_vcpu->evtchn_upcall_pending)) \
#define raw_local_irq_disable() \
do { \
- vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
- _vcpu->evtchn_upcall_mask = 1; \
+ current_vcpu_info()->evtchn_upcall_mask = 1; \
barrier(); \
} while (0)
do { \
vcpu_info_t *_vcpu; \
barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
+ _vcpu = current_vcpu_info(); \
_vcpu->evtchn_upcall_mask = 0; \
barrier(); /* unmask then check (avoid races) */ \
if (unlikely(_vcpu->evtchn_upcall_pending)) \
#define write_cr0(x) \
__asm__ __volatile__("movl %0,%%cr0": :"r" (x))
-#define read_cr2() \
- (HYPERVISOR_shared_info->vcpu_info[smp_processor_id()].arch.cr2)
+#define read_cr2() (current_vcpu_info()->arch.cr2)
#define write_cr2(x) \
__asm__ __volatile__("movl %0,%%cr2": :"r" (x))
* Interrupt control:
*/
-#ifdef CONFIG_SMP
-#define __vcpu_id smp_processor_id()
-#else
-#define __vcpu_id 0
-#endif
-
/*
* The use of 'barrier' in the following reflects their use as local-lock
* operations. Reentrancy must be prevented (e.g., __cli()) /before/ following
* includes these barriers, for example.
*/
-#define __raw_local_save_flags() \
- (&HYPERVISOR_shared_info->vcpu_info[__vcpu_id])->evtchn_upcall_mask;
+#define __raw_local_save_flags() (current_vcpu_info()->evtchn_upcall_mask)
#define raw_local_save_flags(flags) \
do { (flags) = __raw_local_save_flags(); } while (0)
do { \
vcpu_info_t *_vcpu; \
barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
+ _vcpu = current_vcpu_info(); \
if ((_vcpu->evtchn_upcall_mask = (x)) == 0) { \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \
#define raw_local_irq_disable() \
do { \
- vcpu_info_t *_vcpu; \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
- _vcpu->evtchn_upcall_mask = 1; \
+ current_vcpu_info()->evtchn_upcall_mask = 1; \
barrier(); \
} while (0)
do { \
vcpu_info_t *_vcpu; \
barrier(); \
- _vcpu = &HYPERVISOR_shared_info->vcpu_info[__vcpu_id]; \
+ _vcpu = current_vcpu_info(); \
_vcpu->evtchn_upcall_mask = 0; \
barrier(); /* unmask then check (avoid races) */ \
if ( unlikely(_vcpu->evtchn_upcall_pending) ) \